<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

//管理员和菜单
use App\Http\Controllers\Admin\AdminController;

Route::prefix('admin')->group(function () {
   //登录
    Route::post('/login', [AdminController::class, 'login']);
    Route::any('/resetToken', [AdminController::class, 'refresh']);
    Route::middleware('checkLogin')->get('/info', [AdminController::class, 'me']);
    Route::middleware('checkLogin')->post('/logout', [AdminController::class, 'logout']);
    //菜单
    Route::middleware('checkLogin')->get('/get_menu', [AdminController::class, 'getMenus']);
    Route::middleware('checkLogin')->post('/create_menu', [AdminController::class, 'createMenus']);
    Route::middleware('checkLogin')->get('/del_menu', [AdminController::class, 'delMenus']);

    //管理员
    Route::middleware('checkLogin')->get('/admin_list', [AdminController::class, 'adminList']);
    Route::middleware('checkLogin')->post('/create', [AdminController::class, 'create']);
    Route::middleware('checkLogin')->get('/delete', [AdminController::class, 'del_admin']);
    Route::middleware('checkLogin')->post('/edit_count', [AdminController::class, 'editCount']);
    //电表相关的接口
    Route::middleware('checkLogin')->any('/importDevice', [AdminController::class, 'importDevice']);
    Route::middleware('checkLogin')->any('/deviceList', [AdminController::class, 'deviceList']);
    Route::middleware('checkLogin')->any('/deviceDisable', [AdminController::class, 'deviceDisable']);
    Route::middleware('checkLogin')->any('/deviceDel', [AdminController::class, 'deviceDel']);
    Route::middleware('checkLogin')->any('/getUserCallDayFlow', [AdminController::class, 'getUserCallDayFlow']);
    Route::middleware('checkLogin')->any('/addCallCount', [AdminController::class, 'addCallCount']);
    Route::middleware('checkLogin')->any('/getAddCallCountHistory', [AdminController::class, 'getAddCallCountHistory']);
    Route::middleware('checkLogin')->any('/getDeviceCallDayFlow', [AdminController::class, 'getDeviceCallDayFlow']);
    Route::middleware('checkLogin')->any('/reset_token', [AdminController::class, 'resetToken']);
    Route::middleware('checkLogin')->any('/setApiUrl', [AdminController::class, 'setApiUrl']);
    Route::middleware('checkLogin')->any('/getDashBoardInfo', [AdminController::class, 'getDashBoardInfo']);
    Route::middleware('checkLogin')->any('/downloadDemo', [AdminController::class, 'downloadDemo']);
    Route::middleware('checkLogin')->any('/exportCsv', [AdminController::class, 'exportCsv']);

    //测试相关
    Route::middleware('checkLogin')->post('/sendMsg', [AdminController::class, 'sendMsg']);


    //
    Route::middleware('checkLogin')->get('/record/list', [\App\Http\Controllers\Admin\RecordController::class, 'list']);
    Route::middleware('checkLogin')->get('/record/del', [\App\Http\Controllers\Admin\RecordController::class, 'del']);
});



use App\Http\Controllers\Admin\UploadController;

Route::prefix('upload')->group(function () {
    Route::post('/image', [UploadController::class, 'saveImg']);
    Route::post('/zip', [UploadController::class, 'saveZip']);
    Route::post('/base_zip', [UploadController::class, 'baseZip']);
    Route::post('/base_image', [UploadController::class, 'baseImg']);
    Route::post('/audio', [UploadController::class,'audio']);
    Route::post('/back_image', [UploadController::class, 'backImg']);
//    Route::post('/image', [UploadController::class, 'uploadOss']);
    Route::get('/test',[UploadController::class, 'test']);
    Route::post('/upload_doc', [UploadController::class, 'uploadDoc']);
    Route::get('/thumb_oss',[UploadController::class, 'thumb_oss']);
    Route::post('/upload_oss', [UploadController::class, 'uploadOss']);
});


Route::post('/test/record',[\App\Http\Controllers\Admin\TestController::class, 'testRecord']);



//首页
use App\Http\Controllers\Admin\StaticsController;

Route::prefix('dashboard')->group(function () {
    Route::get('/scrollnum', [StaticsController::class, 'scrollNum']);
    Route::post('/save_todo', [StaticsController::class, 'save_todo']);
    Route::get('/get_todo', [StaticsController::class, 'get_todo']);
    Route::get('/get_chart', [StaticsController::class, 'chartData']);
    Route::get('/get_pie', [StaticsController::class, 'pieData']);
    Route::get('/month_data', [StaticsController::class, 'month_data']);
    Route::get('/month_data_user', [StaticsController::class, 'month_data_user']);
    Route::get('/pass_data', [StaticsController::class, 'passing']);
});


use App\Http\Controllers\Admin\RolesController;

Route::middleware('checkLogin')->prefix('roles')->group(function(){
    Route::get('/list', [RolesController::class, 'list']);
    Route::get('/all', [RolesController::class, 'all']);
    Route::get('/detail', [RolesController::class, 'detail']);
    Route::get('/roles_detail', [RolesController::class, 'roles_detail']);
    Route::get('/del', [RolesController::class, 'del']);
    Route::post('/create', [RolesController::class, 'create']);
    Route::post('/save_roles', [RolesController::class, 'save_roles']);
});

//banner图
use App\Http\Controllers\Admin\BannerController;
Route::middleware('checkLogin')->prefix('banner')->group(function(){
    Route::post('/create', [BannerController::class, 'create']);
    Route::get('/list', [BannerController::class, 'list']);
    Route::get('/del', [BannerController::class, 'del']);
});



use App\Http\Controllers\Admin\NormalController;
Route::middleware('checkLogin')->prefix('normal')->group(function(){
    Route::get('/detail', [NormalController::class, 'detail']);
    Route::post('/create', [NormalController::class, 'create']);
});



use App\Http\Controllers\IndexController;

Route::any('/notify_test', [IndexController::class, 'notifyTest']);
